package com.lisx.module_time_block.activity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.fenghuajueli.libbasecoreui.adapter.DefaultViewPagerAdapter;
import com.fenghuajueli.libbasecoreui.mvp.BaseActivity;
import com.fenghuajueli.libbasecoreui.utils.MyStatusBarUtils;
import com.fenghuajueli.module_route.TimeBlockModuleRoute;
import com.ijianji.lsx_ui_lib.TabLayout;
import com.lisx.module_time_block.databinding.ActivityTimeBlockListBinding;
import com.lisx.module_time_block.fragment.TimeBlockItemFragment;

import java.util.ArrayList;
import java.util.List;

@Route(path = TimeBlockModuleRoute.TIME_BLOCK_ACTIVITY)
public class TimeBlockListActivity extends BaseActivity {

    @Autowired(name = "position")
    int position;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityTimeBlockListBinding binding = ActivityTimeBlockListBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        MyStatusBarUtils.setStatusBar(this,"#5AB4C7");
        List<String> titleList = new ArrayList<>();
        List<Fragment> fragmentList = new ArrayList<>();
        titleList.add("起床");
        titleList.add("早晨");
        titleList.add("中午");
        titleList.add("晚上");
        titleList.add("周计划");
        titleList.add("月计划");
        for (int i = 0; i < titleList.size(); i++) {
            TimeBlockItemFragment fragment = new TimeBlockItemFragment();
            Bundle bundle = new Bundle();
            bundle.putInt("index", i);
            fragment.setArguments(bundle);
            fragmentList.add(fragment);
        }
        DefaultViewPagerAdapter adapter = new DefaultViewPagerAdapter(getSupportFragmentManager(), titleList, fragmentList, 1);
        binding.viewpager.setAdapter(adapter);
        binding.tabLayout.setupWithViewPager(binding.viewpager);
        binding.viewpager.setCurrentItem(position);

        binding.ivFanhui.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
